package com.bnyy.medicalHousekeeper.moudle.wallet.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.SpanUtils;
import com.bnyy.common.adapter.BaseNormalListAdapter;
import com.bnyy.medicalHousekeeper.R;
import com.bnyy.wallet.bean.BankCardInfo;

public class BankCardAdapter extends BaseNormalListAdapter<BankCardInfo, BankCardAdapter.ViewHolder> {

    private View.OnClickListener l;

    public BankCardAdapter(Context context, View.OnClickListener l) {
        super(context);
        this.l = l;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(inflater.inflate(R.layout.item_bank_card, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        BankCardInfo bankCardInfo = getData(position);
        holder.tvBank.setText(bankCardInfo.getBank_name());
        String bankCardNo = bankCardInfo.getBank_card_no();
        SpanUtils.with(holder.tvBankCardNum)
                .append("••••  ••••  ••••  ")
                .append(bankCardNo.substring(bankCardNo.length() - 4)).setFontSize(18,true)
                .create();

//        holder.tvBankCardNum.setText("••••  ••••  ••••  " + bankCardNo.substring(bankCardNo.length() - 4));
        holder.root.setTag(bankCardInfo);
        holder.root.setOnClickListener(l);
    }


    public static class ViewHolder extends BaseNormalListAdapter.ViewHolder {

        TextView tvBank, tvBankCardType, tvBankCardNum;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvBank = itemView.findViewById(R.id.tv_bank);
            tvBankCardType = itemView.findViewById(R.id.tv_bank_card_type);
            tvBankCardNum = itemView.findViewById(R.id.tv_bank_card_num);
        }
    }
}


















































